/* xxxio.h
 * By: Spencer Clark
 * Date created: March 19th 2011
 * Date modified: March 19th 2011
 * Modified by: Spencer Clark
 */

#ifndef _XXXOS_XXXIO_H
#define _XXXOS_XXXIO_H

#include <stdint.h>


/* Colours available in VGA text mode */
#define BLACK         0x0
#define BLUE          0x1
#define GREEN         0x2
#define BALL_BLUE     0x3
#define RED           0x4
#define PURPLE        0x5
#define ORANGE        0x6
#define GREY          0x7
#define GRAY          0x7
#define CHARCOAL      0x8
#define SLATE_BLUE    0x9
#define LIME_GREEN    0xA
#define AQUA          0xB
#define CORAL         0xC
#define MAGENTA       0xD
#define YELLOW        0xE
#define WHITE         0xF

/* Simple macro to set up a colour for printing characters:
 * background: a 4-bit colour (as above) to use as the background
 * foreground: a 4-bit colour (as above) to use as the foreground
 */
#define char_colour(background,foreground) (((background) << 4) | (foreground))

/* The default colour used for printing characters */
#define DEFAULT_TEXT_COLOUR char_colour(BLACK, GREY)

/* Initialization needed for xxxio functions (essentially, this clears the
 * VGA memory that xxxio uses to print characters)
 */
void xxxio_init(void);

/* Procedure clear_screen:
 * Clear all characters on the screen.
 */
void clear_screen(void);

/* Procedure xprintf:
 * Print a char* with formatting. Roughly analagous to C's printf but
 * not as fancy. Supported formats:
 *  signed integer: %i
 *  signed integer (as hexadecimal): %x
 *  unsigned integer: %u
 *
 *  newline: \n
 *  tab: \t
 *
 *  percent: %%
 *  backslash: \\
 */
void xprintf(char*, ...);

/* Procedure xprintf_c:
 * Exactly as xprintf above, except it takes as its first parameter a 1-byte
 * value which indicates the colour to print the string in.
 * Note: Use char_colour() to set the colour
 */
void xprintf_c(uint8_t, char*, ...);

/* Procedure xprintc:
 * Print a single character to the screen with the default colour
 */
void xprintc(const char);

/* Procedure xprintc_c:
 * Exactly as xprintc above, except it take as its first parameter a 1-byte
 * value indicating hte colour to print the character in.
 */
void xprintc_c(uint8_t, const char);

#endif /* _XXXOS_XXXIO_H */
